package com.bby.screentool.utils;

import android.util.Log;

import com.bby.screentool.event.ScreenModelObserver;

import org.webrtc.SdpObserver;
import org.webrtc.SessionDescription;

public class SdpObserverAdapter implements SdpObserver {
    private final String TAG = "SdpObserverAdapter";
    private final ScreenModelObserver viewModelObserver;
    private final SdpCallBack callback;
    public SdpObserverAdapter(ScreenModelObserver viewModelObserver, SdpCallBack callback) {
        this.viewModelObserver = viewModelObserver;
        this.callback = callback;
    }

    @Override
    public void onCreateSuccess(SessionDescription sdp) {
        callback.onSuccess(this, sdp);
    }

    @Override
    public void onSetSuccess() {

    }

    @Override
    public void onCreateFailure(String s) {
        Log.e(TAG, "Offer 资源创建失败: " + s);
        viewModelObserver.onMessageShow("Offer 创建失败！");
    }

    @Override
    public void onSetFailure(String s) {
        Log.e(TAG, "Offer 资源添加失败: " + s);
        viewModelObserver.onMessageShow("Offer 设置失败！");
    }

    public interface SdpCallBack {
        void onSuccess(SdpObserver observer, SessionDescription description);
    }
}
